﻿using Mes.Domain.BoundedContext.Entities.Quality;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.Quality
{
    public class SpcRuleEntityConfig : IEntityTypeConfiguration<SpcRule>
    {
        public void Configure(EntityTypeBuilder<SpcRule> builder)
        {
            builder.ToTable("spc_rule");
            builder.HasKey(b => b.Rule_Id);
            builder.Property(b => b.Rule_Desc).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Use_For_Ix).IsRequired();
            builder.Property(b => b.Use_For_Mr).IsRequired();
            builder.Property(b => b.Use_For_Xbar).IsRequired();
            builder.Property(b => b.Use_For_Range).IsRequired();
            builder.Property(b => b.Use_For_Sigma).IsRequired();
            builder.Property(b => b.Use_For_Ma).IsRequired();
            builder.Property(b => b.Use_For_Ewmaix).IsRequired();
            builder.Property(b => b.Use_For_Run).IsRequired();
            builder.Property(b => b.Use_For_Attr).IsRequired();
            builder.Property(b => b.Test1);
            builder.Property(b => b.Test2);
            builder.Property(b => b.And_Not_Or).IsRequired();
            builder.Property(b => b.Level1);
            builder.Property(b => b.Level2);
            builder.Property(b => b.Num_Points).IsRequired();
            builder.Property(b => b.Of_Points).IsRequired();
            builder.Property(b => b.Priority).IsRequired();
            builder.Property(b => b.Obsolete).IsRequired();
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Created_By).HasMaxLength(40).IsRequired();
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Created_At).IsRequired();
            builder.Property(b => b.Rule_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
